/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2024.
 * Description: RTOS self-developed code for route.c
 * Author: Wang Haitao
 * Create: 2023/9/14
 */

#ifdef CONFIG_RTOS_NET_ROUTE_QUERY_ERR
static void trace_vendor_skb_dst_set_noref(struct net *net, struct sk_buff *skb,
						   struct flowi6 *fl6, int flags)
{
	struct dst_entry *entry = NULL;

	entry = ip6_route_input_lookup(net, skb->dev, fl6, skb, flags);
	if (entry && entry->error) {
		if (g_route_query_err)
			(*g_route_query_err)(INPUT_ROUTING, AF_INET6, skb, NULL);
	}
	skb_dst_set_noref(skb, entry);
}

INDIRECT_CALLABLE_SCOPE struct rt6_info *ip6_pol_route_output(struct net *net,
					     struct fib6_table *table,
					     struct flowi6 *fl6,
					     const struct sk_buff *skb,
					     int flags);

static struct dst_entry *trace_vendor_fib6_rule_lookup(struct net *net,
							struct flowi6 *fl6, int flags)
{
	struct dst_entry *entry = NULL;

	entry = fib6_rule_lookup(net, fl6, NULL, flags, ip6_pol_route_output);
	if (entry && entry->error) {
		if (g_route_query_err)
			(*g_route_query_err)(OUTPUT_ROUTING, AF_INET6, NULL, fl6);
	}
	return entry;
}
#else

static void trace_vendor_skb_dst_set_noref(struct net *net, struct sk_buff *skb,
						   struct flowi6 *fl6, int flags)
{
}

static struct dst_entry *trace_vendor_fib6_rule_lookup(struct net *net,
							struct flowi6 *fl6, int flags)
{
	return NULL;
}
#endif